#ifndef __PIC_H__
#define __PIC_H__

#include <types.h>

#define PIC_ICW1                0x11
#define PIC_ICW2                0x03
#define PIC_ICW3_A              0x04
#define PIC_ICW3_B              0x02
#define PIC_ICW4                0x01

#define PIC_IMR_NONE            0x00
#define PIC_IMR_ALL             0xff

#define PIC_IMR_IRQ0            0x01
#define PIC_IMR_IRQ1            0x02
#define PIC_IMR_IRQ2            0x04
#define PIC_IMR_IRQ3            0x08
#define PIC_IMR_IRQ4            0x10
#define PIC_IMR_IRQ5            0x20
#define PIC_IMR_IRQ6            0x40
#define PIC_IMR_IRQ7            0x80
#define PIC_IMR_IRQ8            0x01
#define PIC_IMR_IRQ9            0x02
#define PIC_IMR_IRQ10           0x04
#define PIC_IMR_IRQ11           0x08
#define PIC_IMR_IRQ12           0x10
#define PIC_IMR_IRQ13           0x20
#define PIC_IMR_IRQ14           0x40
#define PIC_IMR_IRQ15           0x80

#define PIC_IRR_READ            0x0A
#define PIC_ISR_READ            0x0B

#define PIC_EOI                 0x20

#define PIC_SMM_CLEAR           0x48
#define PIC_SMM_SET             0x68

#define PIC_EOI_IRQ0            0x60
#define PIC_EOI_IRQ1            0x61
#define PIC_EOI_IRQ2            0x62
#define PIC_EOI_IRQ3            0x63
#define PIC_EOI_IRQ4            0x64
#define PIC_EOI_IRQ5            0x65
#define PIC_EOI_IRQ6            0x66
#define PIC_EOI_IRQ7            0x67

#define PIC_EOI_IRQ8            0x60
#define PIC_EOI_IRQ9            0x61
#define PIC_EOI_IRQ10           0x62
#define PIC_EOI_IRQ11           0x63
#define PIC_EOI_IRQ12           0x64
#define PIC_EOI_IRQ13           0x65
#define PIC_EOI_IRQ14           0x66
#define PIC_EOI_IRQ15           0x67

void remap_pic(uchar master, uchar slave);
void mask_irq(uchar irqn);
void unmask_irq(uchar irqn);
void send_eoirq(uchar irqn);
uchar get_irqmask();
void set_irqmask(uchar irqn);
void pic_init(void);

#endif	/* __PIC_H__ */

